<?php 
## include required files
/*******************************/
require_once '../model/cms.php';
require_once '../model/moduleuser.php';
/*******************************/
## Create Objects
/*******************************/
$cmsObj = new Model_CMS();
$moduleObj=new Model_ModuleUser();
/*******************************/
if($_GET['q']=='defaultseo')
{
	$moduelArray=$moduleObj->getModuleHelpText(6);
	$smarty->assign('moduelArray', $moduelArray);
}

if(isset($_POST['addcms_btn'])) {
	## apply PHP validation for required filed
	if(trim($_POST['meta_title']) != '' && trim($_POST['meta_keyword']) != '') {
		$seoArray = array();
		extract($_POST);
		$seoArray['meta_title']      = return_post_value($meta_title);
		$seoArray['meta_keyword']    = return_post_value($meta_keyword);
		$seoArray['meta_description']= return_post_value($meta_description);
		$seoArray['analytics']= return_post_value($analytics);
		
		$cmsObj->updateDefaultSeo($seoArray, 1);
		
		$_SESSION['msg'] = "<div class='success_msg'><span>Default SEO updated successfully</span></div>";
		header('location:'.SITE_URL.'/admin/home.php?q=defaultseo');
		exit;
	} else {// php validation else
		$_SESSION['msg'] = "<div class='error_msg'><span>Please enter all the required fields</span></div>";
	}
	// main if closed
}

## Get default seo
$default_seo = $cmsObj->getfeDefaultSeo();
$smarty->assign('default_seo', $default_seo);

## Assign success or error msg to smarty variable and unset session variable
if(trim($_SESSION['msg']) != '') {
	$smarty->assign('msg', $_SESSION['msg']);
	unset($_SESSION['msg']);
}

## Set active class variable for left menu
$smarty->assign('activeclass', 'defaultseo');
$smarty->assign('mainmenu', '5');
## Unset all the objects created which are on this page
unset($cmsObj);
unset($moduleObj);

$smarty->display(TEMPLATEDIR_ADMIN. 'settings/defaultseo.tpl');
unset($smarty);
?>